﻿Imports System.Data.OleDb
Public Class ParentRegistration
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' If Not IsPostBack Then

        'Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("TutorsConnectionString").ConnectionString)
        ' Dim SqlString As String = "SELECT * FROM tblParents WHERE TuteeID=@f1"
        'Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        ' cmd.CommandType = CommandType.Text

        ' cmd.Parameters.AddWithValue("@f1", User.Identity.Name)
        ' oleDbConn.Open()
        ' Dim dr As OleDbDataReader = cmd.ExecuteReader()
        '  If dr.HasRows() Then
        'dr.Read()
        ' If Not IsDBNull(dr("Title")) Then ddl_title.SelectedValue = dr("Title")
        ' If Not IsDBNull(dr("FirstName")) Then tb_FirstName.Text = dr("FirstName")
        ' If Not IsDBNull(dr("LastName")) Then tb_LastName.Text = dr("LastName")
        ' If Not IsDBNull(dr("PostCode")) Then tb_PostCode.Text = dr("PostCode")
        'If Not IsDBNull(dr("EmailAddress")) Then tbEmailAddress.Text = dr("EmailAddress")
        ' If Not IsDBNull(dr("Telephone")) Then tbEmailAddress.Text = dr("Telephone")
        ' End If
        ' End If
    End Sub

    Protected Sub btn_SaveProfile_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_SaveProfile.Click

        Dim SqlString As String
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("TutorsConnectionString").ConnectionString)
        SqlString = "UPDATE tblParents SET Title=@f1,FirstName=@f2,LastName=@f3,Location=@f4,EmailAddress=@f5, Telephone=@F6, SubjectRequest=@f7 WHERE TuteeID=@f8"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text

        cmd.Parameters.AddWithValue("@f1", ddl_title.SelectedValue)
        cmd.Parameters.AddWithValue("@f2", tb_FirstName.Text)
        cmd.Parameters.AddWithValue("@f3", tb_LastName.Text)
        cmd.Parameters.AddWithValue("@f4", tb_PostCode.Text)
        cmd.Parameters.AddWithValue("@f5", tbEmailAddress.Text)
        cmd.Parameters.AddWithValue("@f6", tbTelephone.Text)
        cmd.Parameters.AddWithValue("@f7", tbSubjectRequest.Text)
        cmd.Parameters.AddWithValue("@8", User.Identity.Name)
        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        oleDbConn.Close()
        oleDbConn.Dispose()
        Response.Redirect("ParentProfile.aspx?TuteeID=" & User.Identity.Name)

    End Sub


End Class